const express = require( 'express' );

const router = express.Router();

function myRender( resp , viewName ){
    resp.render( viewName , (err,html)=>{
        if(err){
            resp.send( '<p style="color:red">模板渲染失败</p>' );
            return ;
        }
        resp.send( html );
    });
}

router.get( '/add' , (req,resp) => {
    // /views/course/add.njk
    myRender( resp , 'course/add' );
});

router.get( '/edit' , (req,resp) => {
    // /views/course/edit.njk
    myRender( resp , 'course/edit' )
});


module.exports = router ;